FROM node:20-alpine AS builder

WORKDIR /app

# Install git (Alpine doesn't include it by default)
RUN apk add --no-cache git

COPY . .

# Clone the submodule
RUN git submodule update --init --recursive

# Install Node deps
RUN npm ci

# Build the app
RUN NEXT_IGNORE_TYPE_ERRORS=true npm run build


FROM node:20-alpine

WORKDIR /app
COPY --from=builder /app ./
ENV NODE_ENV=production

EXPOSE 3000
CMD ["npm", "start"]
